<template>
    <div>
        <!-- 顶部滑动条 -->
        <div id="slider" class="mui-slider">
				<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
					<div class="mui-scroll">
						<a :class="['mui-control-item',item.id==1 ? 'mui-active' : '']" v-for="item in cates" :key="item.id" @click="getPhotoList(item.id)">
							{{item.title}}
						</a>
						
					</div>
				</div>

		</div>
            
            <!-- photo -->
            <ul class="photo-list">
                <li v-for="item in list" :key="item.id">
                    <img v-lazy="item.img_url">
                    <div class="info">
                        <h1 class="title">{{item.title}}</h1>
                        <div class="body">{{item.zhaiyao}}</div>
                    </div>
                </li>
            </ul>
    </div>
</template>

<script>
import mui from '../../lib/mui/js/mui.js'

export default {
    
    data(){
        return {
            
            list:[
                // {id:1,addr:require('./pictrure/aniu.jpg')},
                // {id:2,addr:require('./pictrure/bz.jpg')},
                
                // {id:3,addr:require('./pictrure/aniu.jpg')},
                // {id:4,addr:require('./pictrure/bz.jpg')}
          
            ],
            cates:[]
        }
    },
    created(){
        this.getAllCategory()
        this.getPhotoList(1)
    },
    mounted(){
        mui('.mui-scroll-wrapper').scroll({
    deceleration:0.0005
    })
    },
    methods:{
        getAllCategory(){//获取所有图片
        this.$http.get('picture/tagbar.json').then(result =>{
            if(result.body.status === 0){
                this.cates = result.body.message
            }
        })
        },
        getPhotoList(cateId){
        var urlId=cateId + '.json'
        // console.log(urlId)
        this.$http.get('picture/'+urlId).then(result=>{
            if(result.body.status === 0){
                this.list = result.body.message
            }
        })
    }
    }
    
}
</script>

<style lang="scss" scoped>
*{
    touch-action: pan-y;
}

// img{
//     width: 100%;
//     height: 100%;
// }
.photo-list{
    margin:0;
    padding: 10px;
    list-style: none;
    padding-bottom: 0;
    li{
        margin-bottom: 10px;
        text-align: center;
        background-color: #ccc;
        box-shadow: 0 0 8px #999;
        position: relative;
        img{
            width: 100%;
            height: 100%;
            vertical-align: middle;
        }
        img[lazy=loading] {
        width: 40px;
        height: 300px;
         margin: auto;
        }
        .info{
            color:white;
            width: 100%;
            position: absolute;
            bottom: 0;
            text-align: left;
            background: rgba(0,0,0,.3);
            .title{
                font-size: 14px;
            }
            .body{
                font-size: 13px;
            }
        }
    }
}
</style>
